<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="./template.xhtml">

    <ui:define name="title">
        Quản lý cấu hình account
    </ui:define>

    <ui:define name="content">
        <h:form>
            <p:panel header="Quản lý account" id="inputForm">
                <h:panelGrid columns="2">
                    <h:outputText value="AccountID của CP: "/>
                    <p:inputText value="#{scratchAccManagement.userId}"/>
                    <h:outputText value="Nhập password: " />
                    <p:password value="#{scratchAccManagement.userPass}"/>
                    <h:outputText value="Nhập IP: " />
                    <p:inputText value="#{scratchAccManagement.ip}"/>
                    <h:outputText value="Nhập tên CP: " />
                    <p:inputText value="#{scratchAccManagement.cpName}" />
                    <h:outputText value="Nhập địa chỉ CP: " />
                    <p:inputText value="#{scratchAccManagement.cpAddress}" />
                    <h:outputText value="Nhập số điện thoại CP: " />
                    <p:inputText value="#{scratchAccManagement.cpPhone}" />
                    <h:outputText value="Trạng thái Account: " />
                    <h:selectBooleanCheckbox value="#{scratchAccManagement.lock}" />
                    <h:outputText value="Nhập số giao dịch đồng thời: " />
                    <p:inputText value="#{scratchAccManagement.numConcurrentTrans}" />
                    <h:outputText value="Chọn hệ số chia sẻ: " />
                    <h:selectOneMenu value="#{scratchAccManagement.rateLevel}">
                        <f:selectItems value="#{scratchAccManagement.lConfigRate}"></f:selectItems>
                    </h:selectOneMenu>
                    <h:outputText value="Hệ số đặc biệt: " />
                    <p:inputText value="#{scratchAccManagement.specialBonus}" />
                    <p:commandButton value="Cập nhật" update="listAccount" ajax="false"
                                     actionListener="#{scratchAccManagement.updateAccount}"/>
                    <p:messages id="messages" showDetail="true" autoUpdate="true"/> 
                </h:panelGrid>  
            </p:panel>
            <p:panel header="Danh sách account">
                <p:dataTable var="accounts" value="#{scratchAccManagement.lAccs}" id="listAccount" 
                             paginator="true" rows="10"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                             rowsPerPageTemplate="5,10,15" rendered="#{scratchAccManagement.lAccs.size()>0}">  
                    <f:facet name="header">  
                        Danh sách  
                    </f:facet>  

                    <p:column>  
                        <f:facet name="header">  
                            <h:outputText value="AccountId" />  
                        </f:facet>  
                        <h:outputText value="#{accounts.userId}"/>  
                    </p:column>  

                    <p:column>  
                        <f:facet name="header">  
                            <h:outputText value="IP" />  
                        </f:facet>  
                        <h:outputText value="#{accounts.ip}" />  
                    </p:column>  

                    <p:column>  
                        <f:facet name="header">  
                            <h:outputText value="Tên CP" />  
                        </f:facet>  
                        <h:outputText value="#{accounts.cpName}" />  
                    </p:column>  

                    <p:column>  
                        <f:facet name="header">  
                            <h:outputText value="Địa chỉ" />  
                        </f:facet>  
                        <h:outputText value="#{accounts.cpAddress}" />  
                    </p:column>

                    <p:column>  
                        <f:facet name="header">  
                            <h:outputText value="Số điện thoại" />  
                        </f:facet>  
                        <h:outputText value="#{accounts.cpPhone}" />  
                    </p:column>

                    <p:column>  
                        <f:facet name="header">  
                            <h:outputText value="Trạng thái" />  
                        </f:facet>  
                        <h:outputText value="#{accounts.isLocked}" />  
                    </p:column>

                    <p:column>  
                        <f:facet name="header">  
                            <h:outputText value="Số giao dịch đồng thời" />  
                        </f:facet>  
                        <h:outputText value="#{accounts.numConcurrentTrans}" />  
                    </p:column>

                    <p:column>  
                        <f:facet name="header">  
                            <h:outputText value="Hệ số đặc biệt" />  
                        </f:facet>  
                        <h:outputText value="#{accounts.specialBonus}" />  
                    </p:column>
                    <p:column>
                        <f:facet name="header">  
                            <h:outputText value="Cập nhật thông tin" />  
                        </f:facet>  
                        <p:commandButton value="Sửa" actionListener="#{scratchAccManagement.fillInput}"  ajax="false" update="inputForm" id="updateButton">
                            <f:param name="uId" value="#{accounts.userId}"/>
                        </p:commandButton>
                        <p:commandButton value="Xóa" action="#{scratchAccManagement.delete}" ajax="false" update="listAccount">
                            <f:param name="uId" value="#{accounts.userId}"/>
                        </p:commandButton>
                    </p:column>

                </p:dataTable>  
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>
